﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<nwrole.toolbox.sync.entity.SyncEntity>>" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
    <title>Index</title>
    <script src="/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
</head>
<body>
<a href="/entity/index">Entiteter</a> || <a href="/entity/schemaindex">Schema</a><br />

    <div>
    <table>
    <tr>
        <th>Namn</th>
        <th>Tabell</th>
        <th>Importerad</th>
        <th>Val</th>
    </tr>

<% foreach (var e in Model)
   { %>        
        <tr>
            <td>
                <a href="/entity/schemashow?id=<%=e.Id %>&type=<%=e.Type %>"><%=e.Name %></a>
            </td>        
            <td>
                :<%=e.SourceTableName %>:
            </td>        
            <td>
                <%=((e.ImportDat!=null)?e.ImportDat.ToString() : "")%>
            </td>        
            <td>
                <a id="importSchemaLink" href="" onclick="return ImportSchema(this, <%=e.Id %>, <%=e.Type %>);">Importera</a>
            </td>        

        </tr>
<% } %>    
    </table>    
    </div>
    

<script type="text/javascript">
    function ToggleSyncEnabled(obj, colId) {
        $.get('/entity/ToggleSyncEnabled', { id: colId, x: Math.random() }, function (result) {
            if (result.success) {
                if (result.newValue) {
                    $(obj).text('True');
                } else {
                    $(obj).text('False');
                }
            }
            else {
                alert(result.success);
            }
        });
        return false;
    }

    function ImportSchema(obj, id, type) {
        $.get('/entity/ImportSchema', { id: id, type: type, x: Math.random() }, function (result) {
            if (result.success) {
                alert("done");
                $('importSchemaLink').text('Done');
            }
            else {
                alert(result.success);
            }
        });
        return false;
    }
</script>

</body>
</html>
